//2009/08/18 00:57:31
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class FontSize
{
public:
    int getPixelWidth(string sentence, vector <int> uppercase, vector <int> lowercase)
    {
		int sum = 0;
		for(int i=0; i<sentence.size(); i++)
		{
			if(isupper(sentence[i]) != 0) sum += uppercase[sentence[i] - 'A'];
			else if(isalpha(sentence[i]) && !isupper(sentence[i])) sum += lowercase[sentence[i] - 'a'];
			else if(sentence[i] == ' ') sum += 3;
		}
		return sum + sentence.size() - 1;
    }
};
